<template>
	<view class="content-box">
		<navBack></navBack>
		<image class="bg" src="/static/me/bg.png" mode="widthFix"></image>
		<view class="box">
			<view class="type-box">
				<view class="">
					{{$statusText(orderDetail.status)}}
				</view>
				<view class="">
					{{orderDetail.createTime}}
				</view>
			</view>
			<!-- v-if="orderDetail.orderDriverInfo" -->
			<view class="map">
				<map @tap="lookMap=!lookMap" :style="'transition: all .6s;height:'+(lookMap?'900rpx':'300rpx')"
					:markers="markers" :polyline="polyline" :include-points="markers"></map>
			</view>
			<view class="journey-box">
				<view class="left-ico">
					<image src="/static/order/send-ico_.png" mode=""></image>
					<view class="line">

					</view>
					<image src="/static/order/receive-ico_.png" mode=""></image>
				</view>
				<view class="journey-text">
					<view class="text" @click="getLocation(orderDetail.startAddr)">
						<view class="">
							{{orderDetail.startAddr.name||''}}
							<block >
								{{orderDetail.startAddr.phone||''}}
							</block>
						</view>
						<view class="" style="border-bottom: 2rpx solid #E6E6E6;">
							{{orderDetail.startAddr.location||''}}
						</view>
					</view>
					<view class="text" style="margin-top: 28rpx;" @click="getLocation(orderDetail.endAddr)">
						<view class="">
							{{orderDetail.endAddr.name||''}}
							<block>{{orderDetail.endAddr.phone||''}}
							</block>
						</view>
						<view class="" style="padding-bottom: 0;">
							{{orderDetail.endAddr.location||''}}
						</view>
					</view>
				</view>
				<view class="right-ico">
					<image src="/static/order/phone_send.png" mode=""
						v-if="orderDetail.startAddr.phone"
						@click="$makePhoneCall(orderDetail.startAddr.phone)"></image>
					<image src="/static/order/phone_receive.png" mode=""
						v-if="orderDetail.endAddr.phone"
						@click="$makePhoneCall(orderDetail.endAddr.phone)"></image>
				</view>
			</view>

			<view class="card">
				<view class="title">
					行程信息
				</view>
				<view class="form-box">
					<view class="form-item">
						<view class="lable">
							车型选择
						</view>
						<view class="value">
							{{orderDetail.driverTypeName||''}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							宠物数量
						</view>
						<view class="value">
							<text style="padding-right: 20rpx;"
								v-for="item in orderDetail.petInfo">{{item.name}}*{{item.count}}</text>
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							笼具信息
						</view>
						<view class="value">
							<view class="" v-for="item in orderDetail.cageInfo">
								{{item.name}}*{{item.count}}
							</view>
						</view>
					</view>
					<view class="form-item" v-if="orderDetail.familyCount">
						<view class="lable">
							陪人数量
						</view>
						<view class="value">
							{{orderDetail.familyCount||''}}
						</view>
					</view>
					<view class="form-item" v-if="orderDetail.assistantCount">
						<view class="lable">
							副司机数量
						</view>
						<view class="value">
							*{{orderDetail.assistantCount}}
						</view>
					</view>
					<view class="form-item" v-if="orderDetail.escortCount">
						<view class="lable">
							护送师数量
						</view>
						<view class="value">
							*{{orderDetail.escortCount}}
						</view>
					</view>
					<view class="form-item" v-if="orderDetail.insuranceName">
						<view class="lable">
							宠物保险
						</view>
						<view class="value">
							{{orderDetail.insuranceName}}*{{orderDetail.petDetailInfo.length}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							上门时间
						</view>
						<view class="value">
							{{orderDetail.expectPickTime||''}}
						</view>
					</view>
				</view>

			</view>

			<view class="card">
				<view class="title" style="margin-bottom: 6rpx;">
					宠物信息
				</view>
				<view class="pet-box" v-for="(item, index) in orderDetail.petDetailInfo">
					<image :src="$imageUrl(item.image)" mode=""></image>
					<view style="flex: 1;">
						<view class="pet-text">
							<view style="display: flex;justify-content: space-between;">
								<view class="name">
									{{item.name}}
									<image :src="'/static/'+(item.sex==1?'male':'girl')+'.png'" mode="widthFix"></image>
								</view>
								<view class="pet-msg-btn" @click="setPetActiveIndex(index)">
									详细信息
									<view :class="{'pet-btn-active':petActiveIndex==index}">
										<u-icon name="arrow-down" color="#FFCE4E"></u-icon>
									</view>
								</view>
							</view>
							<view style="display: flex;justify-content: space-between;">
								<view class="">
									{{item.categoryName}}·{{item.weight}}kg·{{item.age}}个月
								</view>
								<view class="">
									*{{item.count}}
								</view>
							</view>

						</view>
						<view class="details-box" :class="{'details-box-active':petActiveIndex==index}">
							<view class="">
								每日用餐数：{{item.mealsNumber}}次
							</view>
							<view class="">
								{{item.petLove}}
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="card" style="padding:20rpx;" v-if="orderDetail.petJourneyList">
				<view class="dynamic-condition" v-for="(item, index) in orderDetail.petJourneyList">
					<view class="dynamic-condition-left">
						<image
							:src="'/static/order/'+(index===orderDetail.petJourneyList.length-1?'underway':'finish')+'.png'"
							mode=""></image>
						<view class="line" v-if="index!==orderDetail.petJourneyList.length-1">

						</view>
					</view>
					<view class="dynamic-condition-right">
						<view class="stare-box">
							<text>{{index===orderDetail.petJourneyList.length-1?'小可爱出发了':'宠宝宝旅途休息时间'}}</text>
							<text>{{item.createTime}}</text>
						</view>
						<view class="type">
							{{item.remark||''}}
						</view>
						<view class="media-box">
							<image :src="$imageUrl(imgItem)" @click="$util.enlargement(item.images,imgIndex)"
								v-for="(imgItem, imgIndex) in item.images" mode=""></image>
							<view class="video" v-for="(videoItem) in item.videoInfoList" style="position: relative;">
								<image src="/static/play.png" mode=""
									style="width: 40rpx;height: 40rpx;position: absolute;top: 50%;left: 50%;transform: translate(-50% ,-50%);">
								</image>
								<image :src="$imageUrl(videoItem.cover)"
									@click="$routeTo('/pages/orderDetails/lookVideo?url='+videoItem.url)" mode="">
								</image>
							</view>

						</view>
						<view class="type">
							{{item.label||''}}
						</view>
						<view class="dynamic-condition-location">
							<image src="/static/order/place_ico.png" mode="heightFix"></image>
							<text>{{item.fullAddress}}</text>
						</view>
					</view>
				</view>
			</view>

			<view class="card">
				<view class="title">
					订单信息
				</view>
				<view class="form-box">
					<view class="form-item">
						<view class="lable">
							订单编号
						</view>
						<view class="value">
							{{orderDetail.orderNo||''}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							运输距离
						</view>
						<view class="value">
							{{orderDetail.mileage||''}}km
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							订单金额
						</view>
						<view class="value">
							￥{{orderDetail.paidPrice===null?'**':orderDetail.paidPrice}}
						</view>
					</view>
					
					<view class="form-item" v-if="orderDetail.couponPrice">
						<view class="lable">
							优惠金额
						</view>
						<view class="value">
							￥{{orderDetail.couponPrice===null?'**':orderDetail.couponPrice}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							已付金额 <text v-if="orderDetail.payStatus==2">(定金)</text>
						</view>
						<view class="value">
							￥{{orderDetail.amountPaid===null?'**':orderDetail.amountPaid}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							创建时间
						</view>
						<view class="value">
							{{orderDetail.createTime||''}}
						</view>
					</view>
					<view class="form-item">
						<view class="lable">
							订单备注
						</view>
						<view class="value">
							{{orderDetail.remark||'无'}}
						</view>
					</view>
				</view>
			</view>
			<view class="card serve" @click="$makePhoneCall()">
				<image src="/static/server-ico.png" mode=""></image>
				<view class="">
					联系客服
				</view>
			</view>

			<!-- 		<view class="btn-box">
			
						<view class="btn1" v-if="orderDetail.status===3||orderDetail.status===5">
							取消订单
						</view>
						<view class="btn2" v-if="orderDetail.status===4">
							支付尾款
						</view>
					</view> -->
		</view>
		<Loading />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				textDot: 0,
				orderDetail: {
					paidPrice:'**',
					amountPaid:'**'
				},
				petActiveIndex: -1,
				polyline: [],
				markers: [],
				lookMap: false
			}
		},
		onLoad(e) {
			this.$myRequest('/api/driver/order/v1/bookingHall/detail', {
				orderId: e.id,
				loginType: 2
			}).then(res => {
				this.orderDetail = res.data
				let points = res.data.distanceInfo.polyline
				this.polyline = [{
					points,
					color: '#53c21d',
					width: 10,
					arrowLine: true
				}]
				this.markers = [{
					latitude: points[0].latitude,
					longitude: points[0].longitude,
					iconPath: '/static/origin.png',
					width: 28,
					height: 28
				}, {
					latitude: points[points.length - 1].latitude,
					longitude: points[points.length - 1].longitude,
					iconPath: '/static/terminus.png',
					width: 28,
					height: 28
				}]
if (this.orderDetail.petJourneyList){
	this.orderDetail.petJourneyList.forEach(item => {
		item.images = item.images.split(',')
	})
}
				
			})

		},
		mounted() {
			setInterval(() => {
				if (this.textDot === 3) return this.textDot = 0
				this.textDot++
			}, 1000)
		},
		methods: {
			setPetActiveIndex(index) {
				this.petActiveIndex = this.petActiveIndex === index ? -1 : index
			},
			getLocation(data) {
				uni.openLocation({
					latitude: data.addressLat,
					longitude: data.addressLng,
					success: function() {
						console.log('success');
					}
				});
			},
			lookVideo() {

			}
		}
	}
</script>

<style lang="scss">
	.content-box {
		background-color: #F5F5F5;
		min-height: calc(100vh - 600rpx);
		padding: 200rpx 20rpx 250rpx 20rpx;

		.box {
			position: relative;
			z-index: 5;
		}

		.bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 1;
		}

		.type-box {
			border: 2rpx dashed rgba(255, 120, 99, 0.651);
			background: linear-gradient(129deg, #FFFFFF 0%, #FFFAD6 49%, #FFFFFF 100%);
			border-radius: 12rpx;
			padding: 14rpx 12rpx 18rpx 22rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 32rpx;
			color: #666666;
			font-weight: bold;
			margin-bottom: 38rpx;

			view:nth-child(2) {
				font-size: 24rpx;
				color: #999999;
				font-weight: 100;
			}

		}

		.map {
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			overflow: hidden;

			map {
				width: 100%;
			}
		}

		.journey-box {
			display: flex;
			background-color: #ffffff;
			padding: 40rpx 20rpx;
			border-radius: 20rpx;

			.left-ico {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-right: 20rpx;

				image {
					width: 40rpx;
					height: 40rpx;
				}

				.line {
					width: 2rpx;
					height: 100rpx;
					background-color: #E1E1E1;
					margin: 8rpx 0;
				}
			}

			.journey-text {
				flex: 1;

				.text {
					view:nth-child(1) {
						font-size: 28rpx;
						color: #333333;
						font-weight: bold;
					}

					view:nth-child(2) {
						font-size: 24rpx;
						color: #999999;
						padding: 14rpx 0 26rpx 0;
					}
				}
			}

			.right-ico {
				width: 30rpx;
				height: 215rpx;
				padding-right: 50rpx;
				margin-left: -20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				image {
					width: 64rpx;
					height: 64rpx;
				}
			}
		}

		.evidence-box {
			background-color: #FFA14D;
			border-radius: 20rpx;
			color: #ffffff;
			margin-top: 20rpx;

			.evidence-title {
				font-size: 32rpx;
				font-weight: bold;
				margin: 0 auto;
				text-align: center;
				padding: 14rpx 0;
			}

			.evidence-hint {
				font-size: 24rpx;
				padding-bottom: 20rpx;
				text-align: center;
			}

			.evidence-num {
				display: flex;
				justify-content: center;
				align-items: center;
				padding-bottom: 42rpx;

				.num {
					width: 74rpx;
					height: 74rpx;
					border-radius: 8rpx;
					background-color: #ffffff;
					font-size: 44rpx;
					color: #7D7D7D;
					font-weight: bold;
					line-height: 74rpx;
					text-align: center;
				}

				.line {
					width: 22rpx;
					height: 4rpx;
					background-color: #ffffff;
					margin: 0 22rpx;
				}
			}
		}

		.card {
			padding: 20rpx 0;
			background-color: #ffffff;
			border-radius: 20rpx;
			margin-top: 20rpx;
			position: relative;

			.title {
				font-size: 28rpx;
				color: #333333;
				font-weight: 700;
				position: relative;
				padding-left: 20rpx;

				&:before {
					content: '';
					width: 12rpx;
					height: 28rpx;
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
					background: #FFCE4E;
					border-radius: 0rpx 8rpx 8rpx 0rpx;
				}
			}

			.driver-box {
				display: flex;
				padding: 20rpx;
				padding-top: 30rpx;

				image {
					width: 118rpx;
					height: 118rpx;
					border-radius: 50%;
					margin-right: 38rpx;
				}

				.driver-text {
					display: flex;
					flex: 1;
					flex-direction: column;
					justify-content: space-between;

					.driver-num {
						font-size: 48rpx;
						color: #333333;
						font-weight: bold;
					}

					.vehicle {
						display: flex;
						align-items: center;
						font-size: 28rpx;
						color: #666666;

						view:nth-child(1) {
							color: #333333;
							font-weight: bold;
							margin-right: 20rpx;
						}
					}
				}
			}

			.complaint-btn {
				font-size: 26rpx;
				color: #999999;
				position: absolute;
				top: 20rpx;
				right: 20rpx;
			}

			.dynamic-condition {
				display: flex;

				.dynamic-condition-left {
					width: 34rpx;
					margin-right: 10rpx;
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 34rpx;
						height: 34rpx;
						margin-top: 5rpx;
					}

					.line {
						flex: 1;
						width: 2rpx;
						background-color: #B9B9B9;
						margin: 6rpx 0;
					}
				}

				.dynamic-condition-right {
					flex: 1;

					.stare-box {
						display: flex;
						justify-content: space-between;
						font-size: 24rpx;
						color: #999999;

						text:nth-child(1) {
							font-size: 28rpx;
							color: #333333;
							font-weight: bold;
						}
					}

					.type {
						font-size: 26rpx;
						color: #666666;
						padding: 10rpx 0 20rpx 0;
					}

					.media-box {
						display: flex;
						flex-wrap: wrap;

						>image,
						>.video {
							width: 238rpx;
							height: 238rpx;
							border-radius: 12rpx;
							margin-right: 20rpx;
							margin-bottom: 20rpx;
							overflow: hidden;

							image {
								width: 238rpx;
								height: 238rpx;
							}
						}
					}

					.dynamic-condition-location {
						display: flex;
						font-size: 26rpx;
						color: #333333;
						font-weight: bold;
						align-items: center;
						padding-bottom: 54rpx;

						image {
							// width: 26rpx;
							height: 30rpx;
							margin-right: 10rpx;
						}
					}
				}
			}


			.pet-box {
				display: flex;
				padding: 40rpx 20rpx 0 20rpx;

				image {
					width: 140rpx;
					height: 140rpx;
					margin-right: 20rpx;
					border-radius: 18rpx;
				}

				.pet-text {
					flex: 1;
					height: 140rpx;
					font-size: 28rpx;
					color: #333333;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.name {
						font-size: 32rpx;
						display: flex;
						align-items: center;

						image {
							width: 44rpx;
							margin-left: 8rpx;
						}
					}

					.pet-msg-btn {
						color: #FFCE4E;
						display: flex;
						align-items: center;

						>view {
							margin-left: 6rpx;
							transform: rotateZ(0deg);
							transition: all .6s;
						}

						.pet-btn-active {
							transform: rotateZ(180deg);
						}
					}
				}

				.details-box {
					font-size: 26rpx;
					color: #666666;
					line-height: 50rpx;
					max-height: 0;
					overflow: hidden;
					transition: all .6s;
					margin-top: 20rpx;
				}

				.details-box-active {
					max-height: 300rpx;
				}
			}

			.form-box {
				padding: 10rpx 20rpx;

				.form-item {
					display: flex;
					justify-content: space-between;
					font-size: 28rpx;
					padding: 19rpx 0;

					.lable {
						color: #999999;
					}

					.value {
						color: #333333;
						font-weight: bold;

						view {
							margin-top: 16rpx;
						}

						view:nth-child(1) {
							margin-top: 0;
						}
					}
				}
			}
		}

		.serve {
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			color: #333333;
			padding: 36rpx 0;

			image {
				width: 56rpx;
				height: 56rpx;
				margin-right: 18rpx;
			}
		}

		.btn-box {
			position: fixed;
			bottom: 0;
			left: 0;
			width: calc(100vw - 40rpx);
			padding: 52rpx 20rpx 38rpx 20rpx;
			display: flex;
			justify-content: flex-end;
			background-color: #ffffff;

			view {
				width: 212rpx;
				height: 64rpx;
				border-radius: 36rpx;
				font-size: 28rpx;
				line-height: 64rpx;
				text-align: center;
				border: 2rpx solid #FFFFFF;
			}

			.btn1 {
				border: 2rpx solid #FF9231;
				color: #FF9231;
			}

			.btn2 {
				background: #FF9231;
				color: #FFFFFF;
				margin-left: 26rpx;
			}
		}
	}


	@keyframes rotateAn {
		0% {
			transform: rotateZ(0deg);
		}

		100% {
			transform: rotateZ(-360deg);
		}
	}
</style>